package com.restaurant.application.indexes.genshanguserList;

import com.nebutown.description.DataTypes;
import com.nebutown.description.IndexGen;
import com.nebutown.description.UnitDescription;
import com.nebutown.description.data.Contributor;
import com.nebutown.description.data.IndexUnit;
import com.nebutown.description.data.SQLColumn;
import com.restaurant.application.genshanguser.GenShangUser;
import com.restaurant.application.indexes.genshanguserList.mysql.GenShangUserListCriteria;

/**
 * @author Administrator
 */
public class AssistGenShangUserListDesc extends UnitDescription {
    public static void main(String[] args) {
        getUnitDescription().run("./");
        IndexGen.run(getDescription(), "src/main/java");
    }

    private static UnitDescription getUnitDescription() {
        UnitDescription desc = UnitDescription.basicUnit(AssistGenShangUserList.class, null);

        desc.addUiFunction("search", GenShangUserListCriteria.class.getName());
        desc.addUiFunction("create", null);
        desc.addUiFunction("modify", null);
        return desc;
    }

    public static IndexUnit getDescription() {
        return new IndexUnit()
                .withName("GenShangUserList")
                .withPackageName(AssistGenShangUserListDesc.class.getPackage().getName() + ".mysql")
                .withSrcLocation("./")
                .addContributors(new Contributor()
                        .withName("userUid")
                        .withNullable(false)
                        .withUnique(true)
                        .withUnitType(GenShangUser.class.getName())
                        .addContribution(getSQLColumn("id", DataTypes.STRING, "用户id", 255))
                        .addContribution(getSQLColumn("number", DataTypes.STRING, "用户id", 255))
                        .addContribution(getSQLColumn("createTime", DataTypes.LONG, "创建时间", 20))
                        .addContribution(getSQLColumn("modifyTime", DataTypes.LONG, "修改时间", 20))
                        .addContribution(getSQLColumn("avatarUrl", DataTypes.STRING, "头像地址", 255))
                        .addContribution(getSQLColumn("nickName", DataTypes.STRING, "登陆名称", 255))
                        .addContribution(getSQLColumn("realName", DataTypes.STRING, "登陆名称", 255))
                        .addContribution(getSQLColumn("gender", DataTypes.STRING, "性别", 255))
                        .addContribution(getSQLColumn("password", DataTypes.STRING, "密码", 255))
                        .addContribution(getSQLColumn("phone", DataTypes.STRING, "手机", 255))
                        .addContribution(getSQLColumn("state", DataTypes.STRING, "状态", 255))
                );
    }

    private static SQLColumn getSQLColumn(String name, DataTypes type, String label, Integer width) {
        return new SQLColumn().withName(name).withType(type).withLabel(label).withWidth(width);
    }
}
